unit SyncUnit;

interface

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Contnrs, TreeUnit;

type
  TSync = class
  private
    TreeViewSync: TTreeView;
    procedure UpdateTreeViewChild(DT: TDataTree; TN: TTreeNode);
  public
    constructor Create(TreeViewSrc: TTreeView);
    procedure UpdateTreeView(DataTree: TDataTree);
  end;

implementation

constructor TSync.Create(TreeViewSrc: TTreeView);
begin
  TreeViewSync := TreeViewSrc;
end;

procedure TSync.UpdateTreeViewChild(DT: TDataTree; TN: TTreeNode);
var
  TreeViewNode: TTreeNode;
  DataTreeNode: TNode;
  I: integer;
  DataTreeChild: TDataTree;
begin

  for I := 0 to DT.Root.GetChildrenCount - 1 do
  begin
    DataTreeNode := DT.Root.GetChild(I);
    TreeViewNode := TreeViewSync.Items.AddChild(TN, DataTreeNode.Info);
    if DataTreeNode.GetChildrenCount > 0 then
    begin
      DataTreeChild := TDataTree.Create(DataTreeNode.Info);
      DataTreeChild.Root := DataTreeNode;
      UpdateTreeViewChild(DataTreeChild, TreeViewNode);
    end;
  end;
end;

procedure TSync.UpdateTreeView(DataTree: TDataTree);
var
  Node: TTreeNode;
begin
  Node := TreeViewSync.Items.AddChild(nil, DataTree.Root.Info);
  UpdateTreeViewChild(DataTree, Node);
end;

end.
